package com.xique.door.service.impl;

import java.util.List;

import com.xique.common.core.text.Convert;
import com.xique.common.core.utils.DateUtils;
import com.xique.common.core.utils.SecurityUtils;
import com.xique.common.datascope.annotation.NeedSetFieldValue;
import com.xique.door.bean.domain.DAdvert;
import com.xique.door.bean.request.advert.AdvertSearchRequest;
import com.xique.door.mapper.DAdvertMapper;
import com.xique.door.service.IDAdvertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 门禁广告Service业务层处理
 * 
 * @author caogq
 * @date 2022-03-11
 */
@Service
public class DAdvertServiceImpl implements IDAdvertService
{
    @Autowired
    private DAdvertMapper dAdvertMapper;

    /**
     * 查询门禁广告
     * 
     * @param id 门禁广告ID
     * @return 门禁广告
     */
    @Override
    public DAdvert selectDAdvertById(Long id)
    {
        return dAdvertMapper.selectDAdvertById(id);
    }

    /**
     * 查询门禁广告列表
     * 
     * @param dAdvert 门禁广告
     * @return 门禁广告
     */
    @Override
    public List<DAdvert> selectDAdvertList(DAdvert dAdvert)
    {
        return dAdvertMapper.selectDAdvertList(dAdvert);
    }

    /**
     * 新增门禁广告
     * 
     * @param dAdvert 门禁广告
     * @return 结果
     */
    @Override
    public int insertDAdvert(DAdvert dAdvert)
    {
        dAdvert.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        dAdvert.setUpdateBy(dAdvert.getCreateBy());
        dAdvert.setCreateTime(DateUtils.getNowDate());
        dAdvert.setUpdateTime(DateUtils.getNowDate());
        return dAdvertMapper.insertDAdvert(dAdvert);
    }

    /**
     * 修改门禁广告
     * 
     * @param dAdvert 门禁广告
     * @return 结果
     */
    @Override
    public int updateDAdvert(DAdvert dAdvert)
    {
        dAdvert.setUpdateTime(DateUtils.getNowDate());
        dAdvert.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        return dAdvertMapper.updateDAdvert(dAdvert);
    }

    /**
     * 删除门禁广告对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteDAdvertByIds(String ids)
    {
        return dAdvertMapper.deleteDAdvertByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除门禁广告信息
     * 
     * @param id 门禁广告ID
     * @return 结果
     */
    @Override
    public int deleteDAdvertById(Long id)
    {
        return dAdvertMapper.deleteDAdvertById(id);
    }

    @Override
    public List<DAdvert> conditionSearchAdvertList(AdvertSearchRequest request) {
        return dAdvertMapper.conditionSearchAdvertList(request);
    }
}
